﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GenericGA.generationmaker.selection
{
    /// <summary>
    /// A class for selecting individuals from a population.
    /// </summary>
    /// <typeparam name="P">The phenotype type, or type of the candidate solutions.</typeparam>
    public abstract class Selection <P>
    {

        /// <summary>
        /// Initialize the selection process based on the population from which selections will be made. For example sorting the population on fitness or finding the total of the fitnessesCache. This method is to be called prior to calling the Select method.
        /// </summary>
        /// <param name="population">The population of individuals which the Select method is to select individuals from.</param>
        /// <param name="fitnessFunction">The fitness function to be used</param>
        public abstract void InitSelection(List<Individual<P>> population, GA<P>.FitnessFunctionType fitnessFunction);

        /// <summary>
        /// Select an individual from the population passed to the method InitSelection.
        /// </summary>
        /// <returns>An individual from the population.</returns>
        public abstract Individual<P> Select();

    }
}
